import request from "@/utils/request";

const TESTPAPERQUESTIONINFO_BASE_URL = "/wz/exam/test_paper_question_info";

class TestPaperQuestionInfoAPI {
  /** 获取试卷试题关联表分页数据 */
  static getPage(queryParams?: TestPaperQuestionInfoPageQuery) {
    return request<any, PageResult<TestPaperQuestionInfoPageVO[]>>({
      url: `${TESTPAPERQUESTIONINFO_BASE_URL}/page`,
      method: "get",
      params: queryParams,
    });
  }

  /**
   * 获取试卷试题关联表表单数据
   *
   * @param id TestPaperQuestionInfoID
   * @returns TestPaperQuestionInfo表单数据
   */
  static getFormData(id: number) {
    return request<any, TestPaperQuestionInfoForm>({
      url: `${TESTPAPERQUESTIONINFO_BASE_URL}/detail?id=` + id,
      method: "get",
    });
  }

  /** 添加试卷试题关联表*/
  static add(data: Ref<TestPaperQuestionInfoForm[]>) {
    return request({
      url: `${TESTPAPERQUESTIONINFO_BASE_URL}/save`,
      method: "post",
      data: data,
    });
  }

  /**
   * 更新试卷试题关联表
   *
   * @param id TestPaperQuestionInfoID
   * @param data TestPaperQuestionInfo表单数据
   */
  static update(data: TestPaperQuestionInfoForm) {
    return request({
      url: `${TESTPAPERQUESTIONINFO_BASE_URL}/update`,
      method: "put",
      data: data,
    });
  }

  /**
   * 批量删除试卷试题关联表，多个以英文逗号(,)分割
   *
   * @param ids 试卷试题关联表ID字符串，多个以英文逗号(,)分割
   */
  static deleteByIds(ids: string) {
    return request({
      url: `${TESTPAPERQUESTIONINFO_BASE_URL}/remove?ids=` + ids,
      method: "delete",
    });
  }
}

export default TestPaperQuestionInfoAPI;

/** 试卷试题关联表分页查询参数 */
export interface TestPaperQuestionInfoPageQuery extends PageQuery {}

/** 试卷试题关联表表单对象 */
export interface TestPaperQuestionInfoForm {
  id?: number;
  /** 试题id */
  questionInfoId?: number;
  /** 试卷id */
  testPaperInfoId?: number;
  /** 分数 */
  mark?: number;
  /** 排序 */
  sort?: number;
}

/** 试卷试题关联表分页对象 */
export interface TestPaperQuestionInfoPageVO {
  /** 试题id */
  questionInfoId?: number;
  /** 试卷id */
  testPaperInfoId?: number;
  /** 分数 */
  mark?: number;
  /** 排序 */
  sort?: number;
}
